package cc.yugu.yhdw.common.protocol.msg02;

import cc.yugu.yhdw.common.protocol.MsgCode;
import cc.yugu.yhdw.common.tool.netty.TypeOperator;
import io.netty.buffer.ByteBuf;

import java.util.ArrayList;
import java.util.List;

public class Msg021000015 extends Msg021 {

    public static final byte ACTION_ADD = (byte) 1;
    public static final byte ACTION_DELETE = (byte) 2;

    public byte action;
    public List<Box> boxList = new ArrayList<Box>();

    @Override
    public int getMsgCode() {
        return MsgCode.MSG_021000015.getCode();
    }

    @Override
    public void readData(ByteBuf buffer) {
        action = buffer.readByte();
        int size = buffer.readInt();
        for(int i = 0; i < size; i++) {
            Box box = new Box();
            box.read(buffer);
            boxList.add(box);
        }
    }

    public class Box extends TypeOperator {
        public String boxNum;
        public byte boxType;

        public void read(ByteBuf buffer) {
            boxNum = readString(buffer);
            boxType = buffer.readByte();
        }
    }
}
